<?php
/**
 * @package Hello_Dolly
 * @version 1.5.1
 */
/*
Plugin Name: My plugin Hello Dolly
Plugin URI: http://wordpress.org/#
Description: this is my first plugin . This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
Author: tongliang
Version: 1.0.0
Author URI: http://ma.tt/
*/

function my_hello_dolly_get_lyric() {
	/** These are the lyrics to Hello Dolly */
	$lyrics = "Leave me out with the waste  
This is not what I do  
It's the wrong kind of place  To be thinking of you  
It's the wrong time  For somebody new  
It's a small crime  And I've got no excuse  
Is that alright?  Give my gun away when it's loaded  
Is that alright?  If u don't shoot it how am I supposed to hold it  
Is that alright?  Give my gun away when it's loaded  
Is that alright  With you?  
Leave me out with the waste  
This is not what I do  
It's the wrong kind of place To be cheating on you  
It's the wrong time  She's pulling me through  
It's a small crime  And I've got no excuse  
Is that alright?  I give my gun away when it's loaded  
Is that alright?  If you dont shoot it, how am I supposed to hold it  
Is that alright?  I give my gun away when it's loaded  
Is that alright?  Is that alright with you?  
Is that alright?  I give my gun away when it's loaded  
Is that alright? 
If you don't shoot it, how am I supposed to hold it  
Is that alright?  
If I give my gun away when it's loaded  
Is that alright?  Is that alright with you?  
Is that alright?  
Is that alright?  Is that alright with you?  
Is that alright?  
Is that alright?  Is that alright with you? ";

	// Here we split it into lines
	$lyrics = explode("\n", $lyrics);

	// And then randomly choose a line
	return wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] );
}

// This just echoes the chosen line, we'll position it later
function my_hello_dolly() {
	$chosen = my_hello_dolly_get_lyric();
	echo "<p id='my_dolly'>$chosen</p>";
}

// Now we set that function up to execute when the admin_footer action is called
add_action('after_content', 'my_hello_dolly');

// We need some CSS to position the paragraph
function my_dolly_css() {
	// This makes sure that the posinioning is also good for right-to-left languages
	$x = ( is_rtl() ) ? 'left' : 'right';

	echo "
	<style type='text/css'>
	#my_dolly {
		color:#5681A7;
		position: absolute;
		top: .3em;
		margin: 0;
		padding: 0;
		$x: 115px;
		font-size: 11px;
	}
	</style>
	";
}
add_action('head', 'my_dolly_css');

?>